package com.luo.shop.controller.admin;

import com.luo.shop.dao.GoodsDao;
import com.luo.shop.pojo.Goods;
import com.luo.shop.pojo.Page;
import com.luo.shop.service.admin.GoodsAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("admin/goods")
public class GoodAdminController{

    @Autowired
    private GoodsAdminService goodsAdminService;

    @GetMapping("delete")
    @ResponseBody
    public String delete(Long id) {
        if (goodsAdminService.delete(id)>0){
            return "ok";
        }
        return "error";
    }

    @PostMapping("update")
    @ResponseBody
    public String update(Goods goods) {
        if (goodsAdminService.update(goods)>0){
            return "ok";
        }
        return "error";
    }

    @PostMapping("save")
    @ResponseBody
    public String save(Goods goods) {
        if (goodsAdminService.save(goods)>0){
            return "ok";
        }
        return "error";
    }

}
